<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>评论页</title>
    <script src="../js/vue.js"></script>
</head>
<body>
<div id="app">
    <div>
        <li v-for="c in comments">{{c}}</li>
    </div>
    <div>
        <span>写评论</span>
        <textarea v-model="newComment"></textarea>
        <button v-on:click="submitComment()">提交评论</button>
    </div>
</div>
<script>
    var app=new Vue({
        el:"#app",
        data:{
            comments:["评论1","评论2","评论3","评论4","评论5",],
            newComment:""
        },
        methods:{
            submitComment:function () {
                const s=this.newComment;
                if(s!==''){
                    this.comments.push(this.newComment);
                    this.newComment="";
                }
            }
        }
    })
</script>
</body>
</html>